<?php
if (file_exists("kb/documents/" . $_FILES["document"]["name"]))
      {
      echo "<h2><center>".$_FILES["document"]["name"] . " File already exists. </h2>";
      }
    else
      {
      move_uploaded_file($_FILES["document"]["tmp_name"],
      "kb/documents/" .$_FILES["document"]["name"]);
	$_POST[document]=$_FILES["document"]["name"];
      echo "<h2><center>File uploaded Stored in: " . "kb/documents/".$_FILES["document"]["name"].'</h2>';
$result=mysql_query("SELECT * FROM tblkb WHERE lognumber='$_GET[l]'");
while($row = mysql_fetch_array($result))
  {
  $users=$row[Users];

  }
      $query="INSERT INTO tblkbdocuments Values ('$_GET[l]','','$date','$time','$_POST[document]','0','','','$users')";
mysql_query($query);
mysql_close();
echo '<center><h2>Added '.$_FILES["document"]["name"].' to KB '.$_GET[l].'<p><a href="index.php?p=kb&l='.$_GET[l].'">Back</a>';
      }


